home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
amigadoslibrary
/
ungetc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
1KB
|
51 lines
/* UnGetC.c V1.1 93-03-03 */
/* ROM library: "dos.library/UnGetC", (V36+) */
/* Copyright 1993, Anders Bjerin, Amiga C Club */
#include <dos/dos.h>
#include <clib/dos_protos.h>
#include <stdio.h>
#include <stdlib.h>
UBYTE *version = "$VER: UnGetC 1.1";
int main( int argc, char *argv[] );
int main( int argc, char *argv[] )
{
BPTR my_file;
LONG collected;
LONG actual;
/* Open an already existing file: */
my_file = Open( "RAM:Important.dat", MODE_OLDFILE );
if( !my_file )
exit( 20 );
/* Collect a character: */
collected = FGetC( my_file );
if( collected == -1 )
{
printf( "Could not collect the character! EOF or Error!\n" );
Close( my_file );
exit( 21 );
}
printf("Character: %c\n", collected);
/* Put back the last read character (-1): */
actual = UnGetC( my_file, -1 );
/* OK? */
if( actual == 0 )
printf( "Could not put back the character!\n" );
else
printf( "Character successfully put back!\n" );
Close( my_file );
exit( 0 );
}